/**
 * =====================================================================================
 *       @file  ngx_atomic.h
 *      @brief  
 *
 *  Detailed description starts here.
 *
 *   @internal
 *     Created  2012年05月11日 10时20分54秒 
 *    Revision  1.0.0.0
 *    Compiler  gcc/g++
 *
 *     @author  luis
 * =====================================================================================
 */

#ifndef H_NGX_ATOMIC_H_INCLUDED_
#define H_NGX_ATOMIC_H_INCLUDED_

typedef long                            ngx_atomic_int_t;
typedef unsigned long                   ngx_atomic_uint_t;
typedef volatile ngx_atomic_uint_t      ngx_atomic_t;

#define ngx_atomic_cmp_set(lock, old, set) __sync_bool_compare_and_swap(lock, old, set)
#define ngx_memory_barrier()    __sync_synchronize()
#define ngx_atomic_fetch_add(value, add) __sync_fetch_and_add(value, add)

#if (__i386__ || __i386 || __amd64__ || __amd64)
#define ngx_cpu_pause()         __asm__ ("pause")
#else
#define ngx_cpu_pause()
#endif

#endif
